# 实现发送一张图片给我定制化模型的web接口得到图片识别结果

import base64, json, requests


def detect_taoci(img):
    request_url = 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/classification/ceramics'
    access_token = '24.1a32d8938fa5942927fbba6b66ef9085.2592000.1605942045.282335-22820225'
    header = {'Content-Type': 'application/json'}
    data = {"image": img, "top_num": 7}
    body = json.dumps(data).encode('utf-8')
    request_url = request_url + "?access_token=" + access_token
    response = requests.post(request_url, body, headers=header)
    result = None
    if response.status_code == 200:
        result = response.json()
    return result
